package com.examplemartin.jpademo.pojo.po.cust;

import com.examplemartin.jpademo.annotation.EntityCheck;
import com.examplemartin.jpademo.pojo.admin.BaseEntity;
import com.examplemartin.jpademo.pojo.po.sell.SellPO;
import java.io.Serializable;
import java.util.List;
import javax.persistence.*;

import com.examplemartin.jpademo.service.CustService;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * 客户实体
 */

@Data
@EqualsAndHashCode(callSuper = true)
@Entity(name = "t_cust")
public class CustPO extends BaseEntity implements Serializable {

  // 客户名
  @EntityCheck(required = true, errRequired = "必须输入客户名")
  private String name;

  // 客户地址
  @EntityCheck(required = true, errRequired = "必须输入客户地址")
  private String address;
  // 联系人
  private String linkman;
  // 电话
  private String phone;
  // email
  private String email;
  // 状态
  private Integer status= CustService.CUST_STATUS_ON;
  // 注释
  private String comment;

  // 客户等级 one
//  private LevelPO levelPO;

  // 销售订单 list
  @OneToMany(mappedBy = "custPO")
  @JsonIgnore
  private List<SellPO> sellPOList;

  @Override
  public String toString() {
    return "CustPO{" +
            "name='" + name + '\'' +
            ", address='" + address + '\'' +
            ", linkman='" + linkman + '\'' +
            ", phone='" + phone + '\'' +
            ", email='" + email + '\'' +
            ", status=" + status +
            ", comment='" + comment + '\'' +
            '}';
  }
}
